package jumpingnotes.codec;

public class CodecTask {
	public static final int CODEC_TASK_STATE_INIT = 0;
	public static final int CODEC_TASK_STATE_PENDING = 1;
	public static final int CODEC_TASK_STATE_STARTED = 2;
	public static final int CODEC_TASK_STATE_DONE = 3;
	
	public static final int CODEC_TASK_CODE_UNDEFINED = -1;
	public static final int CODEC_TASK_CODE_SUCCESS = 0;
	public static final int CODEC_TASK_CODE_GENERAL_FAILURE = 1;
	public static final int CODEC_TASK_CODE_FILE_NOT_FOUND = 2;
	public static final int CODEC_TASK_CODE_ACCESS_DENIED = 3;
	
	private String id;
	private int state;
	private int code;
	private String errorInfo;
	private String inputFilePath;
	private String outputFilePath;
	private String inputFilename;
	private String outputFilename;
	private CodecParams param;
	private Object context; // context object that is tied to the task
	
	public CodecTask(String id, String inputFilename, String outputFilename, CodecParams param) {
		this.state = CODEC_TASK_STATE_INIT;
		this.code = CODEC_TASK_CODE_UNDEFINED;
		this.id = id;
		this.inputFilename = inputFilename;
		this.outputFilename = outputFilename;
		if (param != null) {
			this.param = param;
		} else {
			this.param = new CodecParams();
		}
	}
	
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}
	
	public int getState() {
		return state;
	}
	
	public void setState(int state) {
		this.state = state;
	}
	
	public int getCode() {
		return code;
	}
	
	public void setCode(int code) {
		this.code = code;
	}
	
	public String getErrorInfo() {
		return errorInfo;
	}

	public void setErrorInfo(String errorInfo) {
		this.errorInfo = errorInfo;
	}

	public String getInputFilePath() {
		return inputFilePath;
	}

	public void setInputFilePath(String inputFilePath) {
		this.inputFilePath = inputFilePath;
	}

	public String getOutputFilePath() {
		return outputFilePath;
	}

	public void setOutputFilePath(String outputFilePath) {
		this.outputFilePath = outputFilePath;
	}

	public String getInputFilename() {
		return inputFilename;
	}

	public void setInputFilename(String inputFilename) {
		this.inputFilename = inputFilename;
	}

	public String getOutputFilename() {
		return outputFilename;
	}

	public void setOutputFilename(String outputFilename) {
		this.outputFilename = outputFilename;
	}

	public CodecParams getParam() {
		return param;
	}
	
	public void setParam(CodecParams param) {
		this.param = param;
	}
	
	public Object getContext() {
		return context;
	}

	public void setContext(Object context) {
		this.context = context;
	}

	public String toString() {
		StringBuffer buf = new StringBuffer();
		buf.append("Codec task: Id ").append(id)
		.append(" input ").append(inputFilename)
		.append(" output ").append(outputFilename)
		.append(" state ").append(state)
		.append(" code ").append(code)
		.append(" errorInfo ").append(errorInfo);
		return buf.toString();
	}
}
